<style type="text/css">
<!--
@import url("css/cb_style.css");
-->
.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr {
display: none !important;}
</style>
<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'6fa94bce-3936-48ab-8418-c8d47c214cc8'});</script>
<script>
window.fbAsyncInit = function() {
	FB.init({
		appId   : '0',
		session : null, // don't refetch the session when PHP already has it
		status  : true, // check login status
		cookie  : true, // enable cookies to allow the server to access the session
		xfbml   : true // parse XFBML
		});

		FB.Event.subscribe('edge.create', function(response) {
			
			showdata(response,'plus')	;		
		});
		FB.Event.subscribe('edge.remove', function(response) {
			
			showdata(response,'minus')	;
		});

		};
	
	function showdata(response,sign)
	{
		
			var idarray=response.split("itemid=");
		
			var action="update";
			var id=idarray[1];
			strURL="votelist.php?action="+action+"&sign="+sign+"&id="+id;
			req = getXMLHTTP();
			//alert(strURL);
			//alert("here");
			if (req) 
	{	 
		req.onreadystatechange = function() 
		{
			//alert("state"+ req.readyState+ " : "+req.status);
			if (req.readyState == 4) 
			{
				if (req.status == 200) 
				{	
					var res = req.responseText;
				//alert("first" + res);
				  //  alert(document.getElementById("votesdiv"+id).innerHTML);
				document.getElementById("votesdiv"+id).innerHTML = "";
				document.getElementById("votesdiv"+id).innerHTML = res;
						//getmainlist(id);
					
				}		
			}
		}
	}
	if(strURL)
	{
		 
		req.open("GET", strURL, true);
		req.send(null);	
	}			
	}
function getXMLHTTP() 
{ //fuction to return the xml http object
	xmlhttp=false;	
	try
	{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e)	
	{		
		try
		{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e1)
			{
				xmlhttp=false;
			}
		}
	}
	return xmlhttp;
}
</script>
<!-- slideshow js -->
<script type="text/javascript">

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
 function autoSlide(){
    currentPosition = (currentPosition+1>=numberOfSlides)?0:currentPosition+1;   
    manageControls(currentPosition);
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });  
     t = setTimeout('autoSlide()',5000);     
  }
$(document).ready(function(){
  currentPosition = 0;
  slideWidth = 960;
  slides = $('.slide');
  numberOfSlides = slides.length;
    
  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');
  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });
    $('#slidesContainer').mouseover(function(){clearTimeout(t);});
    $('#slidesContainer').mouseout(function(){t = setTimeout('autoSlide()',5000);});
    $('#rightControl').click(function(){clearTimeout(t);t = setTimeout('autoSlide()',5000);});
    $('#leftControl').click(function(){clearTimeout(t);t = setTimeout('autoSlide()',5000);});      
   setTimeout("autoSlide()",3600);
});
</script>
<!-- end slideshow js -->	
<?php
    $url="http://www.smashlix.com/";
    $_get_battle = new battles_controller();
    $_get_battle_item = new battles_item_controller();
    $slide_show_item = $_get_battle->getLastBattles();
    function getBarImage($percent)
{
	if($percent<=0)	$image = "images/0.jpg";
	else if($percent>0 and $percent<=1) $image = "images/1.jpg";
	else 
	{
		if($percent>1 and $percent<=5) $image = "images/5.jpg";
		elseif($percent>5 and $percent<=10) $image = "images/10.jpg";
		elseif($percent>10 and $percent<=15) $image = "images/15.jpg";
		elseif($percent>15 and $percent<=20) $image = "images/20.jpg";
		elseif($percent>20 and $percent<=25) $image = "images/25.jpg";
		elseif($percent>25 and $percent<=30) $image = "images/30.jpg";
		elseif($percent>30 and $percent<=35) $image = "images/35.jpg";
		elseif($percent>35 and $percent<=40) $image = "images/40.jpg";
		elseif($percent>40 and $percent<=45) $image = "images/45.jpg";
		elseif($percent>45 and $percent<=50) $image = "images/50.jpg";
		elseif($percent>50 and $percent<=55) $image = "images/55.jpg";
		elseif($percent>55 and $percent<=60) $image = "images/60.jpg";
		elseif($percent>60 and $percent<=65) $image = "images/65.jpg";
		elseif($percent>65 and $percent<=70) $image = "images/70.jpg";
		elseif($percent>70 and $percent<=75) $image = "images/75.jpg";
		elseif($percent>75 and $percent<=80) $image = "images/80.jpg";
		elseif($percent>80 and $percent<=85) $image = "images/85.jpg";
		elseif($percent>85 and $percent<=90) $image = "images/90.jpg";
		elseif($percent>90 and $percent<=95) $image = "images/95.jpg";
		elseif($percent>95 and $percent<=100) $image = "images/100.jpg";
	}
	return $image;
}
?>
?>	
		  <!-- Slideshow HTML -->
  <div id="slideshow">
    <div id="slidesContainer">
    <?php foreach($slide_show_item as $slide_item){ ?>
    <div class="slide">
        <h2><?php echo $slide_item->title; ?></h2>
        <?php $battle_item = $_get_battle_item->getslideBattles_item($slide_item->id);
            foreach($battle_item as $battle_info_item){ ?>
            <div>
                <?php if($slide_item->type == 'Video') { 
                    if($battle_info_item->yt_link != ''){
                    ?>
                    <embed width="460" height="280" wmode="transparent" type="application/x-shockwave-flash" src="<?php echo $battle_info_item->yt_link; ?>" />
                <?php 
                    }else{
                        if(strstr($battle_info_item->file_name,".wmv") or strstr($battle_info_item->file_name,".WMV")){?>
                                                                <script type="text/javascript">
                                                                AC_AX_RunContent( 'id','MediaPlayer','width','460','height','280','classid','CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95','standby','Loading Windows Media Player components...','type','application/x-oleobject','codebase','http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112','src','<?php echo "../".$battle_info_item->file_name?>','name','MediaPlayer1','autostart','True','wmode','transparent','filename1','<?php echo "../".$battle_info_item->file_name ?>','showcontrols','True' ); //end AC code
                                                                </script><noscript><object id="MediaPlayer" width=460 height=280 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
                                                                <param name="filename1" value="<?php echo "../".$battle_info_item->file_name ?>">
                                                                <param name="Showcontrols" value="True">
                                                                <param name="autoStart" value="True">
                                                                <param name="wmode" value="transparent">

                                                                <embed type="application/x-mplayer2" src="<?php echo "../".$battle_info_item->file_name?>" name="MediaPlayer1" autoStart="True" wmode="transparent" width="460" height="280" ></embed>

                                                                </object></noscript>		
                                                                <?php
                                                                }
                                                                elseif(strstr($battle_info_item->file_name,".mpg") or strstr($battle_info_item->file_name,".mpeg") or strstr($battle_info_item->file_name,".MPEG") or strstr($battle_info_item->file_name,".MPG") or strstr($battle_info_item->file_name,".avi") or strstr($battle_info_item->file_name,".AVI"))
                                                                {?>
                                                                <script type="text/javascript">
                                                                AC_AX_RunContent( 'id','MediaPlayer1','classid','CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95','codebase','http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701','standby','Loading Microsoft Windows? Media Player components...','type','application/x-oleobject','width','460','height','280','pluginspage','http://www.microsoft.com/Windows/MediaPlayer/','src','<?php echo "../".$battle_info_item->file_name;?>','name','MediaPlayer1','autostart','true','showcontrols','true','volume','-450','filename1','<?php echo "../".$battle_info_item->file_name;?>','animationatstart','true','transparentatstart','true' ); //end AC code
                                                                </script><noscript><object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
                                                                standby="Loading Microsoft Windows? Media Player components..." type="application/x-oleobject" width="640" height="350">
                                                                <param name="fileName1" value="<?php echo "../".$battle_info_item->file_name;?>">
                                                                <param name="animationatStart" value="true">
                                                                <param name="transparentatStart" value="true">
                                                                <param name="autoStart" value="true">
                                                                <param name="showControls" value="true">
                                                                <param name="Volume" value="-450">
                                                                <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="<?php echo "../".$battle_info_item->file_name;?>" name="MediaPlayer1" width=460 height=280 autostart=1 showcontrols=1 volume=-450>
                                                                </object></noscript>
				
                                                          <?php }elseif(strstr($battle_info_item->file_name,".flv") or strstr($battle_info_item->file_name,".FLV")){ ?>
                                                              <script src='../js/AC_RunActiveContent.js' language='javascript'></script>
                                                                <!-- saved from url=(0013)about:internet -->
                                                                <script language='javascript'>
                                                                 AC_FL_RunContent('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0', 'width', '460', 'height', '280', 'src', ((!DetectFlashVer(9, 0, 0) && DetectFlashVer(8, 0, 0)) ? 'js/OSplayer' : 'js/OSplayer'), 'pluginspage', 'http://www.macromedia.com/go/getflashplayer', 'id', 'flvPlayer', 'allowFullScreen', 'true', 'allowScriptAccess', 'always', 'movie', ((!DetectFlashVer(9, 0, 0) && DetectFlashVer(8, 0, 0)) ? 'js/OSplayer' : 'js/OSplayer'), 'FlashVars', 'movie=<?php echo "../".$battle_info_item->file_name;?>&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=Super Mario Brothers Lego Edition&showTitle=yes');
                                                                </script>
                                                                <noscript>
                                                                 <object width='460' height='280' id='flvPlayer'>
                                                                  <param name='allowFullScreen' value='true'>
                                                                   <param name="allowScriptAccess" value="always"> 
                                                                  <param name='movie' value='js/OSplayer.swf?movie=<?php echo $battle_info_item->file_name;?>&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=Super Mario Brothers Lego Edition&showTitle=yes'>
                                                                  <embed src='js/OSplayer.swf?movie=<?php echo $battle_info_item->file_name;?>&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=Super Mario Brothers Lego Edition&showTitle=yes' width='460' height='280' allowFullScreen='true' type='application/x-shockwave-flash' allowScriptAccess='always'>
                                                                 </object>
                                                                </noscript>
                                                    <?php
                                                                }
                                                            }
                    }else{ ?>
                <img src="<?php echo $battle_info_item->file_name; ?>" alt="<?php echo $battle_info_item->title; ?>"  />
                <?php } ?>
                <div>
                <?php
                $per=round($battle_info_item->votes/$slide_item->max_vote*100);
    					?>
                        <div style="margin:5px 0 0 120px;text-align: center;width:225px;height:22px;background-image: url('<?php echo getBarImage($per);?>')"><font  face="Arial" color="#738AB6"><b><?php echo $per."%";?></b></font></div>
                     <!--   <img src="<?php echo getBarImage($per);?>" /><?php echo $per;?>-->
                </div>
                <div>
                    <span style="font: bold 24px times;margin-right:60px;"><?php echo $battle_info_item->title; ?></span>
                    <span>Vote:<b style="color:#FEBE00;margin-left: 5px;"><?php echo $battle_info_item->votes; ?></b></span>
                    <span>	<?php if(isset($_SESSION['user']))
							{
        					?>  
                            <div style="float:right; width:<?php if((strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 9.0")) or (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0"))) echo "50px"; else echo "47px";?>; height:24px; overflow: hidden; background: #EEEEEE">                          
                            	<fb:like href="<?php echo $url;?>index.php?t=<?php echo $battle_info_item->id;?>&im=<?php echo $battle_info_item->fb_theme;?>&data=<?php echo $slide_item->sub_title;?>&id=<?php echo $slide_item->id;?>&itemid=<?php echo $battle_info_item->id;?>" send="false" width="27" show_faces="false">
                            </fb:like>
                            </div>
                            <?php
							}else{
							?>
							    <a style="margin-left:80px;" onclick="$('#login_popup').toggle();$('#notice').hide();" href="#">Sign in to Vote </a>
                            <?php
							}
							?>
                    </span> 	
                </div>
                <p class="clear"></p>
            </div>    
        <?php  }  ?>
        <div class="slide_bottom">
            <p><?php echo $slide_item->sub_title; ?></p>
            <a onclick="location='index.php?bt=<?php echo $slide_item->id ?>'">watch now</a>
            <p class="clear"></p>
        </div>
        <img id="vs_image" src="images/vs.png" alt="VS" />
    </div>
    <?php } ?>
    </div>
  </div>
  <!-- Slideshow HTML -->
		
        
        <!--
			<div id="random_vote">
				Random Votes:
                    
			</div>
			<div id="share_batte">
				Share This Battle:		 
                    <div><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.smashlix.com" data-count="none">Tweet</a>
                    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
                    </div>
                    <div><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
                        <script type="IN/Share" data-url="http://smashlix.com/" data-counter="right"></script></div>
                    <div><a href="https://m.google.com/app/plus/x/?v=compose&content=http://smashlix.com/" onclick="window.open('https://m.google.com/app/plus/x/?v=compose&content=http://smashlix.com/','gplusshare','width=450,height=300,left='+(screen.availWidth/2-225)+',top='+(screen.availHeight/2-150)+'');return false;"><img src="images/plus.png" alt="Share on Google+" width="55" height="22" /></a></div>
                    <div style="top: -5px;"><a name="fb_share" type="button" share_url="http://www.smashlix.com/" style=""></a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>
			</div>
   -->
         
	